/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidad;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author AcerII
 */
@Entity
@Table(name = "carga")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Carga.findAll", query = "SELECT c FROM Carga c"),
    @NamedQuery(name = "Carga.findById", query = "SELECT c FROM Carga c WHERE c.id = :id"),
    @NamedQuery(name = "Carga.findByFecha", query = "SELECT c FROM Carga c WHERE c.fecha = :fecha")})
public class Carga implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Long id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fecha")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cargaId")
    private Collection<CargaDetalle> cargaDetalleCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cargaId")
    private Collection<Posicion> posicionCollection;
    @JoinColumn(name = "usuario_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Usuario usuarioId;
    @JoinColumn(name = "transporte_id", referencedColumnName = "id")
    @ManyToOne
    private Transporte transporteId;
    @JoinColumn(name = "estado_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Estado estadoId;
    @JoinColumn(name = "borrado_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Borrado borradoId;

    public Carga() {
    }

    public Carga(Long id) {
        this.id = id;
    }

    public Carga(Long id, Date fecha) {
        this.id = id;
        this.fecha = fecha;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    @XmlTransient
    public Collection<CargaDetalle> getCargaDetalleCollection() {
        return cargaDetalleCollection;
    }

    public void setCargaDetalleCollection(Collection<CargaDetalle> cargaDetalleCollection) {
        this.cargaDetalleCollection = cargaDetalleCollection;
    }

    @XmlTransient
    public Collection<Posicion> getPosicionCollection() {
        return posicionCollection;
    }

    public void setPosicionCollection(Collection<Posicion> posicionCollection) {
        this.posicionCollection = posicionCollection;
    }

    public Usuario getUsuarioId() {
        return usuarioId;
    }

    public void setUsuarioId(Usuario usuarioId) {
        this.usuarioId = usuarioId;
    }

    public Transporte getTransporteId() {
        return transporteId;
    }

    public void setTransporteId(Transporte transporteId) {
        this.transporteId = transporteId;
    }

    public Estado getEstadoId() {
        return estadoId;
    }

    public void setEstadoId(Estado estadoId) {
        this.estadoId = estadoId;
    }

    public Borrado getBorradoId() {
        return borradoId;
    }

    public void setBorradoId(Borrado borradoId) {
        this.borradoId = borradoId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Carga)) {
            return false;
        }
        Carga other = (Carga) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidad.Carga[ id=" + id + " ]";
    }
    
}
